<template>
    <div id="Detail">
        <div class="detail">
            <component :inputData="detailData" :is="currentComponent"></component>
        </div>
    </div>

</template>

<script>
import detail from "commons/Detail";
import navMenu from "commons/NavMenu";
import baseMixin from "@/mixins/BaseMixin";

export default {
    name: "Detail",
    mixins: [baseMixin],
    data() {
        return {
            newFlag: true,
            selectData: {},
            detailData: {
                importtypeSku: "",
                importtypeCustomer: "",
                importtypeCarton: "",
                importtypeCarrier: "",
                importtypeStorerkey: "",
                importtypePutawayzone: "",
                importtypeB2C: "",
                importtypeB2B:"",
                importtypeASN: "",
                importtypePo:"",
                importtypeLineStop:"",
                importtypeASNDetail:"",
                importtypeReceiptPreflight:"",
                importtypeASNSerialDetail:"",
                importtypeTransfer:"",
                importtypeDeliveryOrder:"",
                importtypeOpeningInventory:"",
                importTypeLoc:""
            },
            detailNav: "1",
            temporary: {},
            componentConfig: [
                {
                    name: "GatherDetail",
                    label: this.$t('common.info'),
                    component: () => import('./page/particulars.vue')
                },
            ]
        }
    },
    computed: {
        currentComponent() {
            return this.componentConfig[this.detailNav - 1].component;
        }
    },
    methods: {
        async getData() {
            try {
                let res = await this.$api.post(`/sysExcelImportRule/selectSysExcelImportRuleList`, {});
                console.log(res);
                
                    res.data.data.forEach((item,index)=> {
                        console.log(item["importType"]);
                        //根据导入类型匹配对应的值
                        //货品
                        if(item["importType"] ===10301){
                            this.detailData.importtypeSku = item["templateId"] ;
                        }
                        //客户
                        if(item["importType"] ===10302){
                            this.detailData.importtypeCustomer = item["templateId"] ;
                        }
                        //纸箱
                        if(item["importType"] ===10303){
                            this.detailData.importtypeCarton = item["templateId"] ;
                        }
                        //承运商
                        if(item["importType"] ===10304){
                            this.detailData.importtypeCarrier = item["templateId"] ;
                        }
                        //货主
                        if(item["importType"] ===10305){
                            this.detailData.importtypeStorerkey = item["templateId"] ;
                        }
                        //库区
                        if(item["importType"] ===10306){
                            this.detailData.importtypePutawayzone = item["templateId"] ;
                        }
                        //B2C订单
                        if(item["importType"] ===10307){
                            this.detailData.importtypeB2C = item["templateId"] ;
                        }
                        // B2B订单
                        // if(item["importType"] ===10308){
                        //     this.detailData.importtypeB2B = item["templateId"] ;
                        // }
                        // 出库订单
                        if (item["importType"] === 10311) {
                          this.detailData.importtypeB2B = item["templateId"];
                        }
                        //ASN/收货单
                      if (item["importType"] === 10309) {
                        this.detailData.importtypeASN = item["templateId"];
                      }
                        //采购订单
                        if(item["importType"] ===10310){
                            this.detailData.importtypePo = item["templateId"] ;
                        }
                        if(item["importType"] ===10314){
                            this.detailData.importtypeLineStop = item["templateId"] ;
                        }
                        if(item["importType"] ===10315){
                            this.detailData.importtypeASNDetail = item["templateId"] ;
                        }
                        if(item["importType"] ===10317){
                            this.detailData.importtypeReceiptPreflight = item["templateId"] ;
                        }
                      if(item["importType"] ===10318){
                        this.detailData.importtypeASNSerialDetail = item["templateId"] ;
                      }
                      if(item["importType"] ===10319){
                        this.detailData.importtypeTransfer = item["templateId"] ;
                      }
                      if(item["importType"] ===10321){
                        this.detailData.importtypeTransfer = item["templateId"] ;
                      }
                      if(item["importType"] ===10323){
                        this.detailData.importtypeOpeningInventory = item["templateId"] ;
                      }
                      if (item["importType"] === 10325) {
                        this.detailData.importTypeLoc = item["templateId"];
                      }
                    });

                
            } catch (e) {
                this.$message.error(e);
            }
        }
    },
    mounted() {
        this.newFlag = this.$store.state.newFlag;
        //判断是否事新建
        if (Object.keys(this.$store.state.skip).length !== 0) {
            let data = this.$store.state.skip;
            this.detailData = data.detail;
            this.selectData = data.routeData;
            this.detailNav = data.detailNav;
        } else {
            if (sessionStorage.getItem("queryData")) {
                this.detailData = JSON.parse(sessionStorage.getItem("queryData"))
                sessionStorage.removeItem("queryData")
            } else {
                this.getData();
            }
        }

    },
    components: {
        "v-detail": detail,
        "v-navMenu": navMenu,
    },

}
</script>

<style scoped>

</style>
